// linked_list.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"
#include "linked_list.h"

//return true if the list is empty

int IsEmpty(List L){
	return L->Next == NULL;
}

//return true if P is the last position of L
int IsLast(Position P,List L){
	if(P == NULL){
		
	}
	return P->Next == NULL;
}

//return the position of X in L, NULL if not found
Position Find(ElementType X, List L){
	Position P;

	P = L->Next;
	while(P != NULL && P->Element != X){
		P = P->Next;
	}

	return P;

}

//delete first occurrence of X from a list
//asume use of a header node

void Delete(ElementType X,List L){
	Position P,TmpCell;

	P = FindPrevious(X,L);

	if(!IsLast(P,L)){
		TmpCell = P->Next;
		P->Next = TmpCell->Next;
		free(TmpCell);
	}

}
//if X is not found, then Next field of returned Position is NULL 
//assumes a header
Position FindPrevious(ElementType X, List L){
	Position P;

	P = L;
	while(P->Next != NULL && P->Element != X)
		P = P->Next;
	
	return P;

}

//Insert(after a legal position P)
//Header implementation assumed
//Parameter L is unused in this implementation

void Insert(ElementType X,List L,Position P){
	

}



int _tmain(int argc, _TCHAR* argv[])
{
	return 0;
}

